package business;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;

public class MyNoteAppRead
{

    private String validTitle = "";
    private String validDate = "";
    private String validNote = "";
    private File openNote;

    public MyNoteAppRead(File note)
    {
        this.openNote = note;
        readNote();
    }

    private void readNote()
    {
        String titleTemp;
        String[] whole;
        try
        {
            BufferedReader readNote = new BufferedReader(new FileReader(openNote));
            int counter = 1;
            while ((titleTemp = readNote.readLine()) != null)
            {
            whole = titleTemp.split("//");
                switch(counter)
                {
                    case 1:
                        validTitle += whole[0];
                        break;
                    case 2:
                        validDate += whole[0];
                        break;
                    default:
                        validNote += whole[0] + "\n";
                }
                counter++;
            }
        } catch (IOException e)
        {
            System.out.println("IO-Exception:" + e.getMessage());
        } catch (Exception e)
        {
            System.out.println("Fehler:" + e.getMessage());
        }
    }

    public String getValidDate()
    {
        return validDate;
    }

    public String getValidNote()
    {
        return validNote;
    }

    public String getValidTitle()
    {
        return validTitle;
    }
    
    
}
